<%@ page pageEncoding="UTF-8"%>
<%@ include file="/common/token.jsp"%>
<%@ include file="/common/user.jsp"%>
<%@ include file="/common/operatehistory.jsp"%>
<%
	// 备注患者
	Integer uid = token.getUid();
	// 此处应添加权限控制，是否有权限查看该患者随访方案
	Integer patientUid = input.getInt("patient_uid", -1);
	String comment = input.getDesc("comment", "").trim();
	if (comment.length() == 0 || comment.length() > 50) {
		Tools.encryptPrint(out, new Message(30041, "备注内容0-50个字符"));
		return;	
	}
	User user = userByUid(patientUid);
	if (user == null) {
		Tools.encryptPrint(out, new Message(30041, "患者不存在"));
		return;		
	}
	List<OperateHistory> commentList = QBuilder.db("basedb").select().from("OperateHistory as o").where(new Where("o.hospital=", hospital).and("o.category=", SECTION_DOCTOR).and("o.operate=", ATTENTION).and("o.status=", STATUS_ENABLE).and("o.uid=", patientUid).and("o.oid=", uid)).query().getResultObj();
	if (isEmpty(commentList)) {
		Tools.encryptPrint(out, new Message(30041, "这不是您的患者"));
		return;
	}
	OperateHistory attentionObj = commentList.get(0);
	attentionObj.setJson("comment", comment);
	DBTools.db("basedb").modItem(attentionObj, attentionObj.getId());
	Tools.encryptPrint(out, msg);
%>
